package com.wang.learn.cloudredis.service.impl;

import com.wang.learn.cloudredis.entity.Student;
import lombok.RequiredArgsConstructor;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;

/**
 * ClassName StudentServiceImpl
 *
 * @author wang
 * Date 2022/4/13 15:17
 */
@Service
@RequiredArgsConstructor
public class StudentServiceImpl {

    final MongoTemplate mongoTemplate;

    public int insertStudent(Student student) {
        try {
            student.setTimer(LocalDateTime.now());
            mongoTemplate.insert(student);
            return 1;
        } catch (Exception e) {
            e.printStackTrace();
            return -1;
        }
    }

}
